import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-03-14
 * Time: 12:58
 */
public class test01 {
//    public static void main1(String[] args) {
//        Scanner in = new Scanner(System.in);
//        int n = in.nextInt();
//        List<String> list = new ArrayList<>();
//        for (int i = 0; i < n; i++) {
//            list.add(in.nextLine());
//        }
//        List<String> list1 = new ArrayList<>(list);
//        Collections.sort(list1);
//        boolean a1 = list.equals(list1);
//        boolean a2 = true;
//        for (int i = 0; i <list.size() - 1 ; i++) {
//            if(list.get(i).length() > list.get(i + 1).length()){
//                a2 = false;
//                break;
//            }
//
//        }
//        if(a1 && a2){
//            System.out.println("both");
//            return;
//        }
//        if(a1){
//            System.out.println("lexicographically");
//            return;
//        }
//        if(a2){
//            System.out.println("lengths");
//            return;
//        }
//        System.out.println("none");
//
//    }

    public static void main(String[] args) throws IOException {
        //BufferedReader从字符流中读取文本并且缓存
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bi.readLine());
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = bi.readLine();
        }
        if(isSortlength(str) && isSortZidin(str)){
            System.out.println("both");
        } else if (isSortZidin(str)) {
            System.out.println("lexicographically");
        }else if (isSortlength(str)) {
            System.out.println("lengths");

        }else {
            System.out.println("none");
        }
    }
    public static boolean isSortZidin(String[] str){
        //用当前的字符串和后一个字符串比较,如果字典序大于后一个,说明排序混乱,直接返回false
        for (int i = 0; i < str.length - 1; i++) {
            if(str[i].compareTo(str[i+1]) > 0){
                return false;
            }
        }
        return true;
    }

    public static boolean isSortlength(String[] str){
        for (int i = 0; i < str.length - 1; i++) {
            if (str[i].length() > str[i+1].length()){
                return false;
            }

        }
        return true;
    }
}
